package com.secret.chain.secretchain.controller.wx;

import com.secret.chain.secretchain.domain.entity.Group;
import com.secret.chain.secretchain.result.Result;
import com.secret.chain.secretchain.service.GroupService;
import org.apache.coyote.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wx/group")
public class GroupController {
    @Autowired
    private GroupService groupService;
    @GetMapping("/find/{creatorId}")
    public Result queryByCreatorId(@PathVariable Integer creatorId){
        Result result = groupService.queryByCreatorId(creatorId);
        return result;
    }
    @PostMapping
    public Result  save(@RequestBody Group group){

        return groupService.save(group);
    }
    @DeleteMapping
    public Result delete(Integer id){
        return groupService.deleted(id);
    }
    @PutMapping
    public Result put(@RequestBody Group group){
        return groupService.put(group);
    }
    // 新增模糊查询方法

    @GetMapping("/search/{keyword}")
    public Result search(@PathVariable String keyword) {
        Result result = groupService.queryByKeyword(keyword);
        return result;
    }
    @GetMapping("{id}")
    public Result queryById(@PathVariable Integer id){
        Result result = groupService.queryById(id);
        return result;
    }



}